#ifndef __WEB_SOCKET_H__
#define __WEB_SOCKET_H__

#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/sendfile.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>

#define MAXLINE 1024
#define MAXBUF 48
#define LISTENQ 1024

typedef struct header {
	char *head;
	int cfd;
	int widx;
	int ridx;
	int limit;
} header;

void unixerror(char *msg);
int openListenfd(int port);
header *initheader(int fd);
void closeClient(header *header);
int readline(header *head, char *buf);
int writen(int fd, void *buf, int count);

void processRequest(int fd);
void parseuri(char *uri, char *filename);
void getfiletype(char *filename, char *filetype);
void clienterror(int fd, char *cause, char *errnum, char *shortmsg, char *longmsg);
void readrequesthdrs(header *header);
void serverstatic(int fd, char *filename, int filesize);

#endif /* __WEB_SOCKET_H__ */
